

# 使用 Xenova/ms-marco-MiniLM-L-6-v2
from haystack import Document
from haystack.components.readers import ExtractiveReader

docs = [Document(content="Paris is the capital of France."), Document(content="Berlin is the capital of Germany.")]

reader = ExtractiveReader()
reader.warm_up()
# 内部使用 AutoModelForQuestionAnswering
output=reader.run(query="What is the capital of France?", documents=docs, top_k=2)
print(output)